package com.edu.servlet;

import com.edu.service.UserNewsService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user/home")
public class UserHomeServlet extends HttpServlet {
    private UserNewsService userNewsService = new UserNewsService();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // 获取轮播图新闻
        request.setAttribute("carouselNews", userNewsService.userGetCarouselNews());

        // 获取随机5条校园风采
        request.setAttribute("campusStyles", userNewsService.userGetRandomCampusStyles(5));

        // 转发到首页
        request.getRequestDispatcher("/user/index.jsp").forward(request, response);
    }
}